﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Yinyue200.Sharp2D.Direct2D.Effects
{
    public class ColorSourceEffect : Effect
    {
        public ColorSourceEffect()
        {
            Name = nameof(ColorSourceEffect);
            SetBoxedProperty("Color", Convert(PropertyValueOwner.CreateSingleArray(new float[] { 255, 0, 0, 0 })),Interop.GRAPHICS_EFFECT_PROPERTY_MAPPING.GRAPHICS_EFFECT_PROPERTY_MAPPING_COLOR_TO_VECTOR4);
            pes.Clear();
            map2.Add("ColorHdr", new PackageTuple.WriteableTuple<int, Interop.GRAPHICS_EFFECT_PROPERTY_MAPPING>(objs.Count-1, Interop.GRAPHICS_EFFECT_PROPERTY_MAPPING.GRAPHICS_EFFECT_PROPERTY_MAPPING_UNKNOWN));
        }


        public override void GetEffectId(out Guid id)
        {
            id = SharpDX.Direct2D1.Effect.Flood;
        }

        public Windows.UI.Color Color
        {
            get
            {
                var array = ((float[])GetProperty(nameof(Color)));
                var color = new SharpDX.Color( new SharpDX.Color4(array).ToVector4());
                return Windows.UI.Color.FromArgb(color.A,color.R,color.G,color.B);
            }
            set
            {
                var color = Yinyue200.Sharp2D.Converter.CommonConverter.ConvertToColorF(value);
                SetProperty(nameof(Color), Convert(PropertyValueOwner.CreateSingleArray(color.ToColor4().ToArray())));
            }
        }
        public float[] ColorHdr
        {
            get
            {
                return ((float[])GetProperty(nameof(Color)));
            }
            set
            {
                SetProperty(nameof(Color), Convert(PropertyValueOwner.CreateSingleArray(value)));
            }
        }
    }
}
